﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZBZH_Manage_Order.PublicMethod;

namespace ZBZH_Manage_Order.Controllers.MerchantsSettings
{
    public class OrgShangjiaController : BaseController
    {
        //企业上架管理
        // GET: /OrgShangjia/
        ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
        OrgDC.Service1Client orgdc = new OrgDC.Service1Client();

        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 获取管理员下面的商户
        /// </summary>
        /// <returns></returns>
        public ActionResult getmer()
        {
            try
            {
                Page<Model.OrgOrder_Mer_T> page = new Page<Model.OrgOrder_Mer_T>();
                List<Model.OrgOrder_Mer_T> list = new List<Model.OrgOrder_Mer_T>();//定义商品分类设置
                Model.View_OperUser user = (Model.View_OperUser)Session[SessionStorage.OperUser];

                if (user == null)
                {
                    return RedirectToAction("LoginPage", "Login");  //czx:修改为登录者的Session异常时，直接跳转到登录页面
                }

                string result = service.GetMer(user.OperID, YZM, 1);
                JObject searcho = JObject.Parse(result);//将服务返回的结果进行优化
                string bs = searcho["BS"].ToString();//获取返回结果是否正常标识
                if (bs == "1")//返回结果正常
                {
                    var a = searcho["rows"].Children().ToJson();
                    return Json(a, JsonRequestBehavior.AllowGet);
                }
                return Json(searcho["Msg"].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
